const fs = require('fs'); 
const path = require("path")
const { app } = require("electron");
const Router = require('koa-router') 
const router = new Router()


var all = { list:[], search:[],docs:[] }
let filepath = path.join( app.getPath("userData") ,'copy-doc.json');

router.get('/api/docs', async function(ctx, next) {
    ctx.body = {  data: all.docs }
})
router.post('/api/docs', async function(ctx, next) {
    let { body  } = ctx.request 
    all.docs = body.docs || []
    fs.writeFileSync(filepath,JSON.stringify(all))
    ctx.body = {  code:0, msg: 'ok' }
})
module.exports = router
 